package cn.milolab.djback.controller;

import cn.milolab.djback.annotation.DJRoleCheck;
import cn.milolab.djback.bean.entity.Employee;
import cn.milolab.djback.bean.request.LoginRequest;
import cn.milolab.djback.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

/**
 * @author milowang
 */
@RestController("/")
public class LoginController {
    @Autowired
    LoginService loginService;

    @PostMapping("login")
    @DJRoleCheck(Employee.RoleLevel.UNREGISTERED)
    public Map<String, Object> login(@RequestBody LoginRequest request){
        return loginService.login(request.getCode(), request.getAvatarUrl());
    }
}
